package com.web.star.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageInfo;
import com.web.star.eneity.Page;
import com.web.star.eneity.TBMenu;
import com.web.star.mapper.SystemMapper;
/**
 * 系统service
 * @author star
 * 
 */
@Service
public class SystemService {
	
	@Autowired
    private SystemMapper systemMapper;
	
	public List<TBMenu> selMenuList() {
		List<TBMenu> menuList = systemMapper.selMenuListByPId("0");
		for (TBMenu menu : menuList) {
			String menuid = menu.getMenuid();
			List<TBMenu> mList = systemMapper.selMenuListByPId(menuid);
			menu.setChildren(mList);
		}
		return menuList;
	}
	
	/**
	 * 带分页的查询
	 * @return
	 */
	public PageInfo<TBMenu> selMenuListByPage() {
		Page page = new Page();
		page.enablePaging();
		List<TBMenu> menuList = systemMapper.selMenuListByPId("0");
		PageInfo<TBMenu> pageInfo = new PageInfo<>(menuList);
		return pageInfo;
	}
}
